package com.hucii.app.activity;

import com.hucii.app.R;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.ListView;
import android.widget.TextView;

/**
 * 必定款
 * @author hongyun.fang
 *
 */
public class MustGoodsStyleActivity extends BaseActivity {

	private ListView lv_list;
	private MyAdapter adapter;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		setView(R.layout.must_goods_style);

		initData();
		initView();
		registerListener();
		display();
	}

	private void initData() {

	}

	private void initView() {

		lv_list = (ListView) findViewById(R.id.lv_list);
	}

	private void registerListener() {

	}

	private void display() {

		adapter = new MyAdapter();
		lv_list.setAdapter(adapter);

	}

	class MyAdapter extends BaseAdapter {

		@Override
		public int getCount() {

			return 10;
		}

		@Override
		public Object getItem(int arg0) {
			return null;
		}

		@Override
		public long getItemId(int arg0) {
			return 0;
		}

		@Override
		public View getView(int arg0, View v, ViewGroup arg2) {

			ViewHolder holder;
			if (v == null) {
				holder = new ViewHolder();
				v = LayoutInflater.from(mContext).inflate(R.layout.must_goods_style_item, null);

				holder.tv_product_no = (TextView) v.findViewById(R.id.tv_product_no);
				holder.tv_product_name = (TextView) v.findViewById(R.id.tv_product_name);
				holder.tv_product_color = (TextView) v.findViewById(R.id.tv_product_color);
				holder.tv_goods_start = (TextView) v.findViewById(R.id.tv_goods_start);
				holder.tv_goods_num = (TextView) v.findViewById(R.id.tv_goods_num);
				holder.tv_money = (TextView) v.findViewById(R.id.tv_money);
				holder.btn_operator = (Button) v.findViewById(R.id.btn_operator);

				v.setTag(holder);
			} else {
				holder = (ViewHolder) v.getTag();
			}

			holder.tv_product_no.setText("TB0000" + arg0);
			holder.tv_product_name.setText("比基尼" + arg0);
			holder.tv_product_color.setText("蓝色" + arg0);
			holder.tv_goods_start.setText("1000" + arg0);
			holder.tv_goods_num.setText("10" + arg0);
			holder.tv_money.setText("10000" + arg0);
			//holder.tv_operator.setText("订购" + arg0);

			if (arg0 % 2 == 0) {
				v.setBackgroundColor(getResources().getColor(R.color.white));
			} else {
				v.setBackgroundDrawable(getResources().getDrawable(R.drawable.window_bg));
			}

			return v;
		}

		class ViewHolder {

			TextView tv_product_no;
			TextView tv_product_name;
			TextView tv_product_color;
			TextView tv_goods_start;
			TextView tv_goods_num;
			TextView tv_money;
			Button btn_operator;

		}
	}

}
